<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  
</head>

<body>

</body>
<script>
  //js的错误捕获用下面两个事件结合使用

  //除了prmise的其他错误
  window.addEventListener("error",function(e){
      console.log(e,450);
      e.preventDefault();
  },true)
  //捕获prmise的错误
  window.addEventListener("unhandledrejection",(e)=>{
    console.log(e.reason,456123);
    e.preventDefault();
    throw e.reason  //throw的原因是使得最终错误在上面的error事件中捕获
  });
  (async ()=>{
    aa
  })()
  sss
</script>
<!-- <script src="xxx.com"></script> -->
<script>
  
</script>
</html>
